package com.flh.crm.settings.service.impl;

import com.flh.crm.settings.dao.DicTypeDao;
import com.flh.crm.settings.dao.DivValueDao;
import com.flh.crm.settings.domain.DicType;
import com.flh.crm.settings.domain.DicValue;
import com.flh.crm.settings.service.DicService;
import com.flh.crm.utils.SqlSessionUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author FLH
 * @Date 2020/7/31 11:09
 * @Version 1.0
 */
public class DicServiceImpl implements DicService {

    private DicTypeDao dicTypeDao = SqlSessionUtil.getSqlSession().getMapper(DicTypeDao.class);
    private DivValueDao divValueDao = SqlSessionUtil.getSqlSession().getMapper(DivValueDao.class);

    @Override
    public Map<String, Object> getAll() {

        Map<String,Object> map  = new HashMap<String, Object>();

        //将字典类型列表取出

        List<DicType> dtList =  dicTypeDao.getTypeList();

        //将字典类型遍历
        for (DicType dt:dtList){

            String code =dt.getCode();

           List<DicValue> dvList =  divValueDao.getListByCode(code);

           map.put(code+"List",dvList);

        }


        return map;
    }
}
